# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudRun.V1alpha1.Model.JobSpec do
  @moduledoc """
  JobSpec describes how the job execution will look like.

  ## Attributes

  *   `activeDeadlineSeconds` (*type:* `String.t`, *default:* `nil`) - Optional. Not supported. Specifies the duration in seconds relative to the startTime that the job may be active before the system tries to terminate it. If set to zero, the system will never attempt to terminate the job based on time. Otherwise, the value must be positive integer. +optional
  *   `backoffLimit` (*type:* `integer()`, *default:* `nil`) - Optional. Specifies the number of retries per instance, before marking this job failed. If set to zero, instances will never retry on failure. +optional
  *   `completions` (*type:* `integer()`, *default:* `nil`) - Optional. Specifies the desired number of successfully finished instances the job should be run with. Setting to 1 means that parallelism is limited to 1 and the success of that instance signals the success of the job. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/ +optional
  *   `parallelism` (*type:* `integer()`, *default:* `nil`) - Optional. Specifies the maximum desired number of instances the job should run at any given time. Must be <= completions. The actual number of instances running in steady state will be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism), i.e. when the work left to do is less than max parallelism. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/ +optional
  *   `template` (*type:* `GoogleApi.CloudRun.V1alpha1.Model.InstanceTemplateSpec.t`, *default:* `nil`) - Optional. Describes the instance that will be created when executing a job.
  *   `ttlSecondsAfterFinished` (*type:* `integer()`, *default:* `nil`) - Optional. Not supported. ttlSecondsAfterFinished limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. When the Job is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is set to zero, the Job won't be automatically deleted. +optional
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :activeDeadlineSeconds => String.t() | nil,
          :backoffLimit => integer() | nil,
          :completions => integer() | nil,
          :parallelism => integer() | nil,
          :template => GoogleApi.CloudRun.V1alpha1.Model.InstanceTemplateSpec.t() | nil,
          :ttlSecondsAfterFinished => integer() | nil
        }

  field(:activeDeadlineSeconds)
  field(:backoffLimit)
  field(:completions)
  field(:parallelism)
  field(:template, as: GoogleApi.CloudRun.V1alpha1.Model.InstanceTemplateSpec)
  field(:ttlSecondsAfterFinished)
end

defimpl Poison.Decoder, for: GoogleApi.CloudRun.V1alpha1.Model.JobSpec do
  def decode(value, options) do
    GoogleApi.CloudRun.V1alpha1.Model.JobSpec.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudRun.V1alpha1.Model.JobSpec do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
